import React, { Component } from 'react'
//1. 导入 prop-types
import PropTypes from 'prop-types';

export default class Props1 extends Component {
  //2. 声明『静态属性』
  static propTypes = {
    name: PropTypes.string.isRequired, // require 需要  isRequired 是必须的
    age: PropTypes.number,
    gender: PropTypes.string
  }

  //default 默认  props 属性
  static defaultProps = {
    name: '张三'
  }

  render() {
    //查看 props 的数据
    // console.log(this.props);
    //解构赋值
    let {name, age, gender} = this.props;
    return (
      <div>
        <ul>
          <li>姓名: {name}</li>
          <li>年龄: {age}</li>
          <li>性别: {gender}</li>
        </ul>
      </div>
    )
  }
}

